Removing the last digits in string [migrated]

Posted by Ruriko on Pro Webmasters See other posts from Pro Webmasters or by Ruriko
Published on 2012-11-26T10:49:25Z Indexed on 2012/11/26 17:27 UTC
Read the original article Hit count: 117

Filed under:

I have a string that looks like this:

[APPLE PIE] Sei Shoujo Sentai Lakers 3 Battle Team Lakers 3 (100% FULL-PIC)_20121104_032834

I want to remove the digits at the end of the string, basically the 16 digits at the end of the string. In the end it should look like this:

[APPLE PIE] Sei Shoujo Sentai Lakers 3 Battle Team Lakers 3 (100% FULL-PIC)

This is my code that I have written so far

var str="[APPLE PIE] Sei Shoujo Sentai Lakers 3 Battle Team Lakers 3 (100% FULL-PIC)_20121104_032834";
var n=str.substr(1,74);
document.write(n);

The problem is the string will be different so each will have different amount of characters. So how I remove the digits at the end of the string in javascript?

© Pro Webmasters or respective owner

Related posts about JavaScript